#!/usr/bin/env python

import dbus

def main():
  bus = dbus.SystemBus()
  wlan0 = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager/Devices/wlan0')
  props = wlan0.getProperties(dbus_interface='org.freedesktop.NetworkManager.Devices')

  if props[4] == True:
    network_path = props[19].split('/')

  print 'Current network: %s' % network_path.pop()

if __name__ == '__main__':
  main()
